﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace WMS.App
{
    public class MessageBoxCommon
    {
        public static readonly string MessageSuccessful = "操作成功！";
        public static readonly string MessageFailure = "操作失败！";

        private static readonly string _Caption = "系统信息";

        public static void Warnings(string text)
        {
            Show_OK(text, MessageBoxIcon.Warning);
        }

        public static void Alert(string text)
        {
            Show_OK(text, MessageBoxIcon.Information);
        }

        public static void Error(string text)
        {
            Show_OK(text, MessageBoxIcon.Error);
        }

        public static void Success()
        {
            Show_OK(MessageSuccessful, MessageBoxIcon.Information);
        }

        public static void Fail()
        {
            Show_OK(MessageFailure, MessageBoxIcon.Error);
        }

        private static void Show_OK(string text, MessageBoxIcon icon)
        {
            MessageBox.Show(text, _Caption, MessageBoxButtons.OK, icon);
        }

        public static bool Confirm(string text, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            DialogResult result = MessageBox.Show(text, _Caption, buttons, icon);
            if (result == DialogResult.OK || result == DialogResult.Yes)
                return true;
            else
                return false;
        }

        public static bool ConfirmDelete()
        {
            return ConfirmDelete("");
        }

        public static bool ConfirmDelete(string info)
        {
            string showInfo = "确定删除吗？";
            if (!string.IsNullOrEmpty(info))
            {
                showInfo = string.Format("确定【{0}】删除吗？", info);
            }
            DialogResult result = MessageBox.Show(showInfo, _Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
            if (result == DialogResult.OK || result == DialogResult.Yes)
                return true;
            else
                return false;
        }

    }
}
